#ifndef __PREPROCESSOR_H__
#define __PREPROCESSOR_H__

#include <string>
#include <vector>

#include "file_manager/file_manager.h"

#include <opencv2/opencv.hpp>

class Preprocessor {
private:
    FileManager file_manager_;

    constexpr static double default_dark_exp = 15.0;

private:
    void calculateResult(const cv::Point& point, const cv::Mat& image, std::vector<cv::Point>& defects);
    void locatePixelDefects(cv::Mat& binaryImage, std::vector<cv::Point>& defects);
    void badPixDynamicDetection(const cv::Mat& src, std::vector<cv::Point>& truePixelDefects);
    ushort bayerMedian(const cv::Mat& input, const cv::Point& center);
    int badPixCorrection(cv::Mat& imgSrc, const cv::Mat& imgBadPix);
    static int demosaic(const cv::Mat& img, cv::Mat& img_color);

public:
    static int readLightFrame(const cv::Mat& img_light, cv::Mat& img_color);
    int readLightFrame(const char* img_path, cv::Mat& img_color);
    int readBadPixMap(const std::string& dark_folder, int user_set_gain, int binning, cv::Mat& img_bad_pix_map, double user_set_exp = default_dark_exp);
    int generateBadPixMap(const cv::Mat& imgDark, cv::Mat& imgBadPix);
    int calibrateLightFrame(const char* img_path, const cv::Mat img_bad_pix_map, cv::Mat& img_color);
};



#endif